package com.diudiutechnology.www.yadiudiu.util.http;

import android.text.TextUtils;

import com.diudiutechnology.www.yadiudiu.util.utils.Constant;
import com.diudiutechnology.www.yadiudiu.util.utils.SharedPreferencesUtil;
import com.diudiutechnology.www.yadiudiu.util.utils.Sundry;

import org.xutils.common.Callback;
import org.xutils.http.HttpMethod;
import org.xutils.http.RequestParams;
import org.xutils.x;

import java.io.File;

/**
 * Created by Administrator on 2017/8/25.
 */

public class HttpClient {


    /**
     * 短信
     * phonenumber 电话号码
     * k  类型  短信类型(注册为1、2找回密码为、3短信登录为、4为修改手机号码、5为添加银行卡、6为三方登录绑定手机号验证)
     */
    public static void note(String phonenumber, String k, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.USERLOGINCALLSMS);
        params.addBodyParameter("mobile", phonenumber);
        params.addBodyParameter("k", k);
        addPOSTPRICODE(params, callback);
    }

    /**
     * 注册
     * mobilephone 电话号码
     * password  密码
     * invatationcode 邀请码
     * smscode  短信验证码
     */
    public static void registration(String mobilephone, String password, String invatationcode, String smscode, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.USERLOGINUSERREGISTER);
        params.addBodyParameter("mobilephone", mobilephone);
        params.addBodyParameter("password", password);
        params.addBodyParameter("invatationcode", invatationcode);
        params.addBodyParameter("smscode", smscode);
        addPOST(params, callback);
    }

    /**
     * 登录
     * mobilephone 电话号码
     * password  密码
     * type  手机类型 3
     * pushtoken 极光
     */
    public static void login(String mobilephone, String password, String pushtoken, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.USERLOGINLOGIN);
        params.addBodyParameter("mobilephone", mobilephone);
        params.addBodyParameter("password", password);
        params.addBodyParameter("type", "3");
        params.addBodyParameter("pushtoken", pushtoken);

        addPOST(params, callback);
    }

    /**
     * 找回密码
     * mobilephone 电话号码
     * newPassword  密码
     * smscode  短信验证码
     */
    public static void Retrieve_password(String mobilephone, String password, String smscode, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.USERLOGINRESETUSERPASSWORD);
        params.addBodyParameter("mobilephone", mobilephone);
        params.addBodyParameter("newPassword", password);
        params.addBodyParameter("smscode", smscode);
        addPOST(params, callback);
    }

    /**
     * 短信登录
     * mobilephone 电话号码
     * smscode  短信验证码
     */
    public static void Text_login(String mobilephone, String smscode, String pushtoken, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.USERLOGINQUICKLOGIN);
        params.addBodyParameter("mobilephone", mobilephone);
        params.addBodyParameter("smscode", smscode);
        params.addBodyParameter("type", "3");
        params.addBodyParameter("pushtoken", pushtoken);
        addPOST(params, callback);
    }

    /**
     * 个人中心首页
     */
    public static void mine(Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.USERCENTERINDEX);
        String userid = getUserid();
        params.addBodyParameter("userid", userid);
        addPOST(params, callback);
    }

    /**
     * 个人消息
     */
    public static void Messages(Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.USERCENTERVIEWSYSTEMMESSAGES);
        String userid = getUserid();
        params.addBodyParameter("userid", userid);
        addPOST(params, callback);
    }

    /**
     * 个人消息消息查看
     */
    public static void seeMessage(String msgid, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.USERCENTERSEEMESSAGE);
        String userid = getUserid();
        params.addBodyParameter("userid", userid);
        params.addBodyParameter("msgid", msgid);
        addPOST(params, callback);
    }

    /**
     * 个人头像
     */
    public static void HeadPortrait(String headPortrait, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.USERCENTEREDITUSERHEADPORTRAIT);
        String userid = getUserid();
        params.addBodyParameter("userid", userid);
        params.addBodyParameter("headPortrait", new File(headPortrait));
        addPOST(params, callback);
    }

    /**
     * 修改昵称
     */
    public static void editNickname(String editNickname, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.USERCENTEREDITNICKNAME);
        String userid = getUserid();
        params.addBodyParameter("userid", userid);
        params.addBodyParameter("nickname", editNickname);
        addPOST(params, callback);
    }

    /**
     * 修改电话号码
     */
    public static void editPhone(String userphone, String smscode, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.USERCENTEREDITPHONE);
        String userid = getUserid();
        params.addBodyParameter("userid", userid);
        params.addBodyParameter("userphone", userphone);
        params.addBodyParameter("smscode", smscode);
        addPOST(params, callback);
    }

    /**
     * 修改密码
     */
    public static void resetLoginPass(String mobile, String password, String smscode, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.USERCENTERRESETLOGINPASS);
        String userid = getUserid();
        params.addBodyParameter("userid", userid);
        params.addBodyParameter("mobile", mobile);
        params.addBodyParameter("password", password);
        params.addBodyParameter("smscode", smscode);
        addPOST(params, callback);
    }

    /**
     * 支付密码
     */
    public static void editPaymentPassword(String password, String smscode, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.USERCENTEREDITPAYMENTPASSWORD);
        String userid = getUserid();
        params.addBodyParameter("userid", userid);
        params.addBodyParameter("newPaymentPassword", password);
        params.addBodyParameter("smscode", smscode);
        addPOST(params, callback);
    }

    /**
     * 展示银行卡
     */
    public static void banklist(Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.USERCENTERBANKLIST);
        String userid = getUserid();
        params.addBodyParameter("userid", userid);
        addPOST(params, callback);
    }

    /**
     * 删除银行卡
     * bankid 银行卡id
     */
    public static void deleBank(String bankid, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.USERCENTERDELEBANK);
        String userid = getUserid();
        params.addBodyParameter("userid", userid);
        params.addBodyParameter("bankid", bankid);

        addPOST(params, callback);
    }

    /**
     * 默认银行卡
     * bankid 银行卡id
     */
    public static void settingbank(String bankid, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.USERCENTERSETTINGBANK);
        String userid = getUserid();
        params.addBodyParameter("userid", userid);
        params.addBodyParameter("bankid", bankid);
        addPOST(params, callback);
    }

    /**
     * 添加身份证
     */
    public static void editIdcardimg(String identification, String idcardnoimg, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.USERCENTEREDITIDCARDIMG);
        String userid = getUserid();
        params.addBodyParameter("userid", userid);
        params.addBodyParameter("identification", identification);
        params.addBodyParameter("idcardnoimg", new File(idcardnoimg));
        addPOST(params, callback);
    }

    /**
     * 添加银行卡
     * username 持卡人姓名
     * banknumber 银行卡
     * rephone 银行预留手机
     * smscode 短信验证码
     * id 身份号码
     */
    public static void addBankCard(String username, String banknumber, String rephone, String smscode, String id, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.USERCENTERADDBANKCARD);
        String userid = getUserid();
        params.addBodyParameter("userid", userid);
        params.addBodyParameter("username", username);
        params.addBodyParameter("banknumber", banknumber);
        params.addBodyParameter("rephone", rephone);
        params.addBodyParameter("smscode", smscode);
        params.addBodyParameter("id", id);
        addPOST(params, callback);
    }

    /**
     * 用户认证学历
     * id 身份证号码
     * username 姓名
     */
    public static void education(String id, String username, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.USERCENTEREDUCATION);
        String userid = getUserid();
        params.addBodyParameter("userid", userid);
        params.addBodyParameter("id", id);
        params.addBodyParameter("username", username);
        addPOST(params, callback);
    }

    /**
     * 用户学历
     */
    public static void academicDetails(Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.USERCENTERACADEMICDETAILS);
        String userid = getUserid();
        params.addBodyParameter("userid", userid);
        addPOST(params, callback);
    }


    /**
     * 上传驾驶证正反面
     * identification 上传标识正面为justimg反面为backimg
     * img 图片
     */
    public static void addcarid(String identification, String idcardnoimg, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.USERCENTERADDCARID);
        String userid = getUserid();
        params.addBodyParameter("userid", userid);
        params.addBodyParameter("identification", identification);
        params.addBodyParameter("img", new File(idcardnoimg));
        addPOST(params, callback);
    }

    /**
     * 上传行驶证正反面
     * identification 上传标识正面为justimg反面为backimg
     * img 图片
     */
    public static void addtravel(String identification, String idcardnoimg, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.USERCENTERADDTRAVEL);
        String userid = getUserid();
        params.addBodyParameter("userid", userid);
        params.addBodyParameter("identification", identification);
        params.addBodyParameter("img", new File(idcardnoimg));
        addPOST(params, callback);
    }

    /**
     * 用户添加或编辑现居住地址
     * province 现居住地址(省)
     * city 	现居住地址(市)
     * area     现居住地址(区)
     * detailedAddress 	现居住地址(详细地址)
     */
    public static void addPresentAddress(String province, String city, String area, String detailedAddress, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.USERCENTERADDPRESENTADDRESS);
        String userid = getUserid();
        params.addBodyParameter("userid", userid);
        params.addBodyParameter("province", province);
        params.addBodyParameter("city", city);
        params.addBodyParameter("area", area);
        params.addBodyParameter("detailedAddress", detailedAddress);
        addPOST(params, callback);
    }


    /**
     * 设置中心----显示用户收货地址
     */
    public static void listDeliveryAddress(Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.USERCENTERLISTDELIVERYADDRESS);
        String userid = getUserid();
        params.addBodyParameter("userid", userid);
        addPOST(params, callback);
    }

    /**
     * 设置中心----设置默认收货地址
     * addressid id
     */
    public static void settingdefaultadd(String addressid, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.USERCENTERSETTINGDEFAULTADD);
        String userid = getUserid();
        params.addBodyParameter("userid", userid);
        params.addBodyParameter("addressid", addressid);

        addPOST(params, callback);
    }

    /**
     * 设置中心----添加收货地址
     * consignee 收货人姓名
     * sex 收货人性别:2为男、3为女、默认为2
     * userphone 收货人电话
     * province  省
     * city       市
     * area        区
     * detailedadd 收货人详细地址
     * longitude   经度
     * latitude   纬度
     */
    public static void addUserAddress(String consignee, String sex, String userphone, String province,
                                      String city, String area, String detailedadd, String longitude, String latitude,
                                      Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.USERCENTERADDUSERADDRESS);
        String userid = getUserid();
        params.addBodyParameter("userid", userid);
        params.addBodyParameter("consignee", consignee);
        params.addBodyParameter("sex", sex);
        params.addBodyParameter("userphone", userphone);
        params.addBodyParameter("province", province);

        params.addBodyParameter("city", city);
        params.addBodyParameter("area", area);
        params.addBodyParameter("detailedadd", detailedadd);
        params.addBodyParameter("longitude", longitude);
        params.addBodyParameter("latitude", latitude);

        addPOST(params, callback);
    }

    /**
     * 设置中心----编辑收货地址
     * id 修改收货地址ID
     * consignee 收货人姓名
     * sex 收货人性别:2为男、3为女、默认为2
     * userphone 收货人电话
     * province  省
     * city       市
     * area        区
     * detailedadd 收货人详细地址
     * longitude   经度
     * latitude   纬度
     */
    public static void editUserAddress(String id, String consignee, String sex, String userphone, String province,
                                       String city, String area, String detailedadd, String longitude, String latitude,
                                       Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.USERCENTEREDITUSERADDRESS);
        String userid = getUserid();
        params.addBodyParameter("userid", userid);
        params.addBodyParameter("id", id);
        params.addBodyParameter("consignee", consignee);
        params.addBodyParameter("sex", sex);
        params.addBodyParameter("userphone", userphone);
        params.addBodyParameter("province", province);

        params.addBodyParameter("city", city);
        params.addBodyParameter("area", area);
        params.addBodyParameter("detailedadd", detailedadd);
        params.addBodyParameter("longitude", longitude);
        params.addBodyParameter("latitude", latitude);

        addPOST(params, callback);
    }

    /**
     * 设置中心----删除收货地址
     * id 	地址ID
     */
    public static void deleDeliveryAddress(String addid, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.USERCENTERDELEDELIVERYADDRESS);
        String userid = getUserid();
        params.addBodyParameter("userid", userid);
        params.addBodyParameter("addid", addid);
        addPOST(params, callback);
    }

    /**
     * 洗车-经纬度
     * longitude 经度
     * latitude 纬度
     */
    public static void graticules(String longitude, String latitude, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.CARWASHGRATICULES);

        params.addBodyParameter("longitude", longitude);
        params.addBodyParameter("latitude", latitude);
        addPOSTPRICODE(params, callback);
    }


    /**
     * 客户信息
     */
    public static void index(Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.COMPANYINFOINDEX);
        String userid = getUserid();
        params.addBodyParameter("userid", userid);
        addPOST(params, callback);
    }

    /**
     * 签到详情页面
     */
    public static void signinDetails(String p, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.USERCENTERSIGNINDETAILS +"?p=" + p);
        String userid = getUserid();
        params.addBodyParameter("userid", userid);
        addPOST(params, callback);
    }

    /**
     * 签到
     */
    public static void userSign(Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.USERCENTERUSERSIGN);
        String userid = getUserid();
        params.addBodyParameter("userid", userid);
        addPOST(params, callback);
    }

    /**
     * 查看红包
     */
    public static void viewredpackets(String addtimes, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.USERCENTERVIEWREDPACKETS);
        String userid = getUserid();
        params.addBodyParameter("userid", userid);
        params.addBodyParameter("addtimes", addtimes);
        addPOST(params, callback);
    }

    /**
     * 红包转入余额页面
     */
    public static void userRedBalance(Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.USERCENTERUSERREDBALANCE);
        String userid = getUserid();
        params.addBodyParameter("userid", userid);
        addPOST(params, callback);
    }

    /**
     * 红包提现
     * num 转入金额
     */
    public static void eedCashWithdrawal(String num, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.USERCENTEREEDCASHWITHDRAWAL);
        String userid = getUserid();
        params.addBodyParameter("userid", userid);
        params.addBodyParameter("num", num);

        addPOST(params, callback);
    }

    /**
     * 用户授信积分详情页面
     */
    public static void creditScore(Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.USERCENTERCREDITSCORE);
        String userid = getUserid();
        params.addBodyParameter("userid", userid);
        addPOST(params, callback);
    }

    /**
     * 我的收藏
     */
    public static void collection(Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.USERCENTERCOLLECTION);
        String userid = getUserid();
        params.addBodyParameter("userid", userid);
        addPOST(params, callback);
    }

    /**
     * 取消收藏
     * collectionId 取消收藏id
     */
    public static void cancel(String collectionId, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.USERCENTERCANCEL);
        String userid = getUserid();
        params.addBodyParameter("userid", userid);
        params.addBodyParameter("collectionId", collectionId);

        addPOST(params, callback);
    }

    /**
     * 提交反馈与建议
     * content 内容
     * phone 电话
     */
    public static void addProposal(String content, String phone, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.COMPANYINFOADDPROPOSAL);
        String userid = getUserid();
        params.addBodyParameter("userid", userid);
        params.addBodyParameter("content", content);
        params.addBodyParameter("phone", phone);
        addPOST(params, callback);
    }

    /**
     * 商家类型
     */
    public static void merchanttype(Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.FORBUSINESSMERCHANTTYPE);
        params.setCacheMaxAge(Constant.HOME_TIME * 1000);
        x.http().request(HttpMethod.POST, params, callback);
    }

    /**
     * 提交图片
     */
    public static void upload(String pic, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.NORMUPLOAD);
        params.addBodyParameter("pic", new File(pic));
        params.addBodyParameter("name", "pic");
        addPOSTPRICODE(params, callback);
    }

    /**
     * 删除图片
     * files 图片路径
     */
    public static void delfile(String pic, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.NORMDELFILE);
        params.addBodyParameter("files", pic);
        addPOSTPRICODE(params, callback);
    }

    /**
     * 删除图片
     * files 图片路径
     * id 	商家id
     */
    public static void delimages(String pic, String id, String picurl, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.NORMDELIMAGES);
        params.addBodyParameter("fication", "2");
        params.addBodyParameter("files", pic);
        params.addBodyParameter("id", id);
        params.addBodyParameter("picurl", picurl);


        addPOSTPRICODE(params, callback);
    }

    /**
     * 商家申请入驻
     * name 店铺名称
     * merchanttype 商家类型
     * legalname        法人姓名
     * phone 手机号
     * province 省份
     * city 城市
     * dist 区县
     * suite 详细地址
     * longitude 经度
     * latitude 纬度
     * email  邮箱
     * license 企业执照
     * idcardfront 身份证正面
     * idcardreverse 身份证反面
     * beinvitedcode 邀请码
     * idcardno 身份证号
     */
    public static void applybusiness(String name, String merchanttype, String legalname, String phone, String province, String city,
                                     String dist, String suite, String longitude, String latitude, String email, String license,
                                     String idcardfront, String idcardreverse, String beinvitedcode, String idcardno, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.FORBUSINESSAPPLYBUSINESS);
        String userid = getUserid();
        params.addBodyParameter("userid", userid);
        params.addBodyParameter("name", name);
        params.addBodyParameter("merchanttype", merchanttype);
        params.addBodyParameter("legalname", legalname);
        params.addBodyParameter("phone", phone);
        params.addBodyParameter("province", province);
        params.addBodyParameter("city", city);
        params.addBodyParameter("dist", dist);
        params.addBodyParameter("suite", suite);
        params.addBodyParameter("longitude", longitude);
        params.addBodyParameter("latitude", latitude);
        params.addBodyParameter("email", email);
        params.addBodyParameter("license", license);
        params.addBodyParameter("idcardfront", idcardfront);
        params.addBodyParameter("idcardreverse", idcardreverse);
        params.addBodyParameter("beinvitedcode", beinvitedcode);
        params.addBodyParameter("idcardno", idcardno);

        addPOSTs(params, callback);
    }

    /**
     * 我申请的商家
     */
    public static void mybusiness(Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.FORBUSINESSMYBUSINESS);
        String userid = getUserid();
        params.addBodyParameter("userid", userid);
        addPOSTs(params, callback);
    }

    /**
     * 查看入驻资料详情
     * id 入驻商家id
     */
    public static void shopdetails(String id, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.FORBUSINESSSHOPDETAILS);
        String userid = getUserid();
        params.addBodyParameter("id", id);
        params.addBodyParameter("userid", userid);
        addPOSTs(params, callback);
    }

    /**
     * 删除申请
     * id 入驻商家id
     */
    public static void delbusiness(String id, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.FORBUSINESSDELBUSINESS);
        String userid = getUserid();
        params.addBodyParameter("id", id);
        params.addBodyParameter("userid", userid);
        addPOSTs(params, callback);
    }

    /**
     * 修改申请资料
     * id 商家id
     * status 2申请修改
     * name 店铺名称
     * merchanttype 商家类型
     * legalname        法人姓名
     * phone 手机号
     * province 省份
     * city 城市
     * dist 区县
     * suite 详细地址
     * longitude 经度
     * latitude 纬度
     * email  邮箱
     * license 企业执照
     * idcardfront 身份证正面
     * idcardreverse 身份证反面
     * beinvitedcode 邀请码
     * idcardno 身份证号
     * profile 简介
     */
    public static void modifieddata(String id, String status, String name, String merchanttype, String legalname, String phone, String province, String city,
                                    String dist, String suite, String longitude, String latitude, String email, String license,
                                    String idcardfront, String idcardreverse, String beinvitedcode, String idcardno, String profile, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.FORBUSINESSMODIFIEDDATA);
        String userid = getUserid();
        params.addBodyParameter("userid", userid);
        params.addBodyParameter("id", id);
        params.addBodyParameter("status", status);

        params.addBodyParameter("name", name);
        params.addBodyParameter("merchanttype", merchanttype);
        params.addBodyParameter("legalname", legalname);
        params.addBodyParameter("phone", phone);
        params.addBodyParameter("province", province);
        params.addBodyParameter("city", city);
        params.addBodyParameter("dist", dist);
        params.addBodyParameter("suite", suite);
        params.addBodyParameter("longitude", longitude);
        params.addBodyParameter("latitude", latitude);
        params.addBodyParameter("email", email);
        params.addBodyParameter("license", license);
        params.addBodyParameter("idcardfront", idcardfront);
        params.addBodyParameter("idcardreverse", idcardreverse);
        params.addBodyParameter("beinvitedcode", beinvitedcode);
        params.addBodyParameter("idcardno", idcardno);
        params.addBodyParameter("profile", profile);
        addPOSTs(params, callback);
    }

    /**
     * 商家中心-干洗 蔬果 洗车 家政 开锁 购车 买房  苦力
     * Data 接口
     */
    public static void cleaning(String Data, Callback.CommonCallback<String> callback) {
        String userid = getUserid();
        RequestParams params = new RequestParams(Constant.COM + Data + "?userid=" + userid);
        addGET(params, callback);
    }

    /**
     * 图片管理
     * 商家id
     */
    public static void markepic(String id, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.FORBUSINESSMARKEPIC);
        params.addBodyParameter("merchantid", id);
        addPOSTPRICODE(params, callback);
    }

    /**
     * 店铺图片管理
     * listpic 列表图片
     * figurepic 广告图多个 | 分隔
     * id 	商家id
     */
    public static void management(String figurepic, String listpic, String id, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.FORBUSINESSMANAGEMENT);
        params.addBodyParameter("figurepic", figurepic);
        params.addBodyParameter("listpic", listpic);
        params.addBodyParameter("id", id);
        addPOSTPRICODE(params, callback);
    }

    /**
     * 打样和上班
     * id 商家id
     * ison 3为打烊 2为上班
     */
    public static void proofing(String id, String ison, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.MERCHANTCENTREPROOFING);

        params.addBodyParameter("id", id);
        params.addBodyParameter("ison", ison);
        addPOSTPRICODE(params, callback);
    }

    /**
     * 开启和取消自动接单
     * id 商家id
     * automatic 2为手动接单3为自动接单
     */
    public static void automaticorder(String id, String automatic, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.MERCHANTCENTREAUTOMATICORDER);

        params.addBodyParameter("id", id);
        params.addBodyParameter("automatic", automatic);
        addPOSTPRICODE(params, callback);
    }

    /**
     * 评论-干洗  买房 购车 开锁 蔬果 苦力 家政 洗车
     * Data 接口
     * merchantid 商家id
     * p 分页
     */
    public static void cleaning(String Data, String merchantid, String p, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Data + "?merchantid=" + merchantid + "&p=" + p);
        addGET(params, callback);
    }

    /**
     * 类别-干洗 蔬果 洗车
     * merchantid 商家id
     * Data 接口
     */
    public static void classtype(String Data, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Data);
        addGET(params, callback);
    }

    /**
     * 干洗  上传 修改 蔬果
     * Data 接口
     * pos 0、上传 1、修改
     * merchantid 店铺id   pos为时0
     * c_id 产品ID   pos为时1
     * classid 分类ID
     * name 	产品名称
     * img 图片
     * price 价格
     * introduction 简介
     */
    public static void Cleaning(String Data, String pos, String id, String classid, String name, String img, String price,
                                String introduction, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Data);
        if (pos.equals("0")) {
            params.addBodyParameter("merchantid", id);

        } else {
            params.addBodyParameter("c_id", id);
        }
        params.addBodyParameter("classid", classid);
        params.addBodyParameter("name", name);
        params.addBodyParameter("img", img);
        params.addBodyParameter("price", price);
        params.addBodyParameter("introduction", introduction);
        addPOSTPRICODE(params, callback);
    }

    /**
     * 商家管理-干洗 蔬果 洗车 家政  购车
     * Data 接口
     * merchantid 店铺ID
     */
    public static void Merchantregulator(String Data, String merchantid, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Data + "?merchantid=" + merchantid);
        addGET(params, callback);
    }

    /**
     * 商家管理 我的楼盘
     * id 入驻商家id
     */
    public static void Bridalchamber(String id, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.BRIDALCHAMBERMANAGEMENT);
        String userid = getUserid();
        params.addBodyParameter("id", id);
        params.addBodyParameter("userid", userid);
        addPOSTs(params, callback);
    }

    /**
     * 产品下架-干洗 蔬果 洗车 家政  购车
     * Data 接口
     * productid       产品ID
     */
    public static void Cleaning(String Data, String productid, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Data + "?productid=" + productid);
        addGET(params, callback);
    }

    /**
     * 楼盘上下架
     * id 入驻商家id
     * audit 2上架3下架
     */
    public static void operatio(String id, String audit, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.BRIDALCHAMBEROPERATIO);
        String userid = getUserid();
        params.addBodyParameter("id", id);
        params.addBodyParameter("audit", audit);
        params.addBodyParameter("userid", userid);
        addPOSTs(params, callback);
    }

    /**
     * 楼盘删除
     * id 入驻商家id
     */
    public static void delbulding(String id, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.BRIDALCHAMBERDELBULDING);
        String userid = getUserid();
        params.addBodyParameter("id", id);
        params.addBodyParameter("userid", userid);
        addPOSTs(params, callback);
    }

    /**
     * 删除-干洗 蔬果 洗车 家政  购车
     * Data 接口
     * productid       产品ID
     */
    public static void del(String Data, String productid, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Data);
        params.addBodyParameter("productid", productid);
        addPOSTPRICODE(params, callback);
    }

    /**
     * 洗车  上传 修改
     * Data 接口
     * pos 0、上传 1、修改
     * merchantid 店铺id   pos为时0
     * <p>
     * productid 产品ID   pos为时1
     * classid 分类ID
     * intro 	简介
     * limousineprice 五座轿车门面价
     * limousinediudiuprice 五座轿车丢丢价
     * suvprice suv/mpv门面价
     * suvdiudiuprice suv/mpv丢丢价格
     * taxiprice 的士门面价格
     * taxidiudiuprice 的士丢丢价格
     */
    public static void CarWash(String Data, String pos, String id, String classid, String intro, String limousineprice, String limousinediudiuprice,
                               String suvprice, String suvdiudiuprice, String taxiprice, String taxidiudiuprice,
                               Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Data);
        if (pos.equals("0")) {
            params.addBodyParameter("merchantid", id);

        } else {
            params.addBodyParameter("productid", id);
        }
        params.addBodyParameter("classid", classid);
        params.addBodyParameter("intro", intro);
        params.addBodyParameter("limousineprice", limousineprice);
        params.addBodyParameter("limousinediudiuprice", limousinediudiuprice);
        params.addBodyParameter("suvprice", suvprice);
        params.addBodyParameter("suvdiudiuprice", suvdiudiuprice);
        params.addBodyParameter("taxiprice", taxiprice);
        params.addBodyParameter("taxidiudiuprice", taxidiudiuprice);
        addPOSTPRICODE(params, callback);
    }

    /**
     * 家政  上传 修改
     * Data 接口
     * pos 0、上传 1、修改
     * merchantid 店铺id   pos为时0
     * id 产品ID   pos为时1
     * classid 分类ID
     * synopsis 	简介
     * directionid 服务方向ID
     * servicemoney 服务价格
     * proportion 服务面积
     * servicetime 	服务时间类型 元/月 、元/时 、元
     */
    public static void addservice(String Data, String pos, String id, String classid, String synopsis, String directionid, String servicemoney,
                                  String servicetime, String proportion,
                                  Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Data);
        if (pos.equals("0")) {
            params.addBodyParameter("merchantid", id);

        } else {
            params.addBodyParameter("id", id);
        }
        params.addBodyParameter("classid", classid);
        params.addBodyParameter("synopsis", synopsis);
        params.addBodyParameter("directionid", directionid);
        params.addBodyParameter("servicemoney", servicemoney);
        params.addBodyParameter("servicetime", servicetime);
        params.addBodyParameter("proportion", proportion);
        addPOSTPRICODE(params, callback);
    }

    /**
     * 订单管理-干洗  买房 购车 开锁 蔬果 苦力 家政 洗车 (未接单 已接单  已完成)
     * Data 接口
     * merchantid 商家id
     * currentPage 分页
     */
    public static void Ordermanage(String Data, String merchantid, String currentPage, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Data + "?merchantid=" + merchantid + "&p=" + currentPage);
        addGET(params, callback);
    }

    /**
     * 接单-干洗 蔬果 洗车 家政
     * Data 接口
     * id       产品ID
     */
    public static void orderreceiving(String Data, String id, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Data);
        params.addBodyParameter("id", id);
        addPOSTPRICODE(params, callback);
    }

    /**
     * 干洗详情-干洗 蔬果
     * Data 接口
     * id       产品ID
     */
    public static void ordermanagede(String Data, String id, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Data + "?id=" + id);

        addGET(params, callback);
    }

    /**
     * 干洗详情-  家政
     * Data 接口
     * id       产品ID
     * merchantid
     */
    public static void housekeepingdetails(String Data, String id, String merchantid, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Data);
        params.addBodyParameter("id", id);
        params.addBodyParameter("merchantid", merchantid);
        addPOSTPRICODE(params, callback);
    }

    /**
     * 接单- 购车
     * Data 接口
     * id       产品ID
     * merchantid  商家id
     */
    public static void Ordermanageaff(String Data, String id, String merchantid, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Data);
        params.addBodyParameter("id", id);
        params.addBodyParameter("merchantid", merchantid);
        String userid = getUserid();
        params.addBodyParameter("userid", userid);
        addPOSTPRICODE(params, callback);
    }

    /**
     * 订单管理-正在洗衣、洗衣完成-干洗 洗车 家政  购车
     * Data 接口
     * id       产品ID
     * state 	7、正在洗衣 8、洗衣完成
     */
    public static void laundry(String Data, String id, String state, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Data);
        params.addBodyParameter("id", id);
        params.addBodyParameter("state", state);
        addPOSTPRICODE(params, callback);
    }

    /**
     * 订单管理-干洗配送完成 蔬果取件 蔬果确认完成
     * Data 接口
     * id       产品ID
     */
    public static void cleaningwc(String Data, String id, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Data);
        params.addBodyParameter("id", id);
        addPOSTPRICODE(params, callback);
    }

    /**
     * 发布楼盘 修改新房
     * Data 接口
     * pos 0、上传 1、修改
     * merids 商家id
     * id 楼盘id pos=1修改
     * pics  轮播图
     * titles 楼盘名称
     * types 用途
     * prices 售价
     * <p>
     * fitmentfinishs 装修
     * orientations 朝向
     * profiles 规划数户
     * addresss 楼盘地址
     * quotationtimes  建于时间
     * otherstimes 产业年限
     * cturetypes 建筑类型
     * layouts 物业公司
     * labellings 标签
     * greeningrates 绿化率
     * longitude 经度
     * latitude 纬度
     * carport 车位配比
     * plotratio 容积率
     * qujian 区间面积
     */
    public static void Bridalchamber(String Data, String pos, String id, String merids, String pics, String titles, String types,
                                     String prices, String fitmentfinishs, String orientations, String profiles,
                                     String addresss, String quotationtimes, String otherstimes, String cturetypes,
                                     String layouts, String labellings, String greeningrates, String longitude, String latitude,
                                     String carport, String plotratio, String qujian, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Data);
        String userid = getUserid();
        params.addBodyParameter("userid", userid);
        if (!pos.equals("0")) {
            params.addBodyParameter("id", id);
        }
        params.addBodyParameter("merids", merids);
        params.addBodyParameter("pics", pics);
        params.addBodyParameter("titles", titles);
        params.addBodyParameter("types", types);
        params.addBodyParameter("prices", prices);
        params.addBodyParameter("fitmentfinishs", fitmentfinishs);
        params.addBodyParameter("orientations", orientations);
        params.addBodyParameter("profiles", profiles);
        params.addBodyParameter("addresss", addresss);
        params.addBodyParameter("quotationtimes", quotationtimes);
        params.addBodyParameter("otherstimes", otherstimes);
        params.addBodyParameter("cturetypes", cturetypes);
        params.addBodyParameter("layouts", layouts);
        params.addBodyParameter("labellings", labellings);
        params.addBodyParameter("greeningrates", greeningrates);
        params.addBodyParameter("longitude", longitude);
        params.addBodyParameter("latitude", latitude);
        params.addBodyParameter("carport", carport);
        params.addBodyParameter("plotratio", plotratio);
        params.addBodyParameter("qujian", qujian);

        addPOSTs(params, callback);
    }

    /**
     * 商家管理 新房详情
     * id 入驻商家id
     * longitude 经度
     * latitude 纬度
     */
    public static void details(String id, String longitude, String latitude, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.BRIDALCHAMBERDETAILS);
        String userid = getUserid();
        params.addBodyParameter("id", id);
        params.addBodyParameter("longitude", longitude);
        params.addBodyParameter("latitude", latitude);
        params.addBodyParameter("userid", userid);
        addPOSTPRICODE(params, callback);
    }

    /**
     * 添加楼盘户型图
     * rid 	楼盘ID
     * area 面积
     * ftype 类型
     * picimage  图片
     */
    public static void addhousetype(String rid, String area, String ftype, String picimage, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.BRIDALCHAMBERADDHOUSETYPE);
        String userid = getUserid();
        params.addBodyParameter("rid", rid);
        params.addBodyParameter("area", area);
        params.addBodyParameter("ftype", ftype);
        params.addBodyParameter("picimage", picimage);

        params.addBodyParameter("userid", userid);
        addPOSTs(params, callback);
    }

    /**
     * 添加楼盘户型图
     * id 	楼盘ID
     */
    public static void hometype(String id, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.BRIDALCHAMBERHOMETYPE);
        String userid = getUserid();
        params.addBodyParameter("id", id);
        params.addBodyParameter("userid", userid);
        addPOSTs(params, callback);
    }

    /**
     * 删除户型
     * id 	楼盘ID
     * files 图片路径
     */
    public static void delhometype(String id, String files, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.BRIDALCHAMBERDELHOMETYPE);
        String userid = getUserid();
        params.addBodyParameter("id", id);
        params.addBodyParameter("files", files);
        params.addBodyParameter("userid", userid);
        addPOSTs(params, callback);
    }


    /**
     * 购车  上传 修改
     * Data 接口
     * pos 0、上传 1、修改
     * productid 店铺id   pos为时0
     * c_id 产品ID   pos为时1
     * photo 图片路径
     * brand 	汽车品牌
     * type 汽车性质
     * guideprice 汽车指导价
     * sellingprice 汽车销售价
     * carcolor 汽车颜色
     * customerservice  汽车售后
     * travel  行驶公里
     * thefactorytime 出厂时间
     * detailedaddress 详细地址
     * detailsa 车辆详情
     * province 省
     * city 市
     * area  区
     * longitude 经度
     * latitude 纬度
     */
    public static void CarBuying(String Data, String pos, String id, String photo, String brand, String type, String guideprice,
                                 String sellingprice, String carcolor, String customerservice, String travel, String thefactorytime,
                                 String detailedaddress, String detailsa, String province, String city, String area,
                                 String longitude, String latitude, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Data);
        if (pos.equals("0")) {
            params.addBodyParameter("productid", id);
        } else {
            params.addBodyParameter("c_id", id);
        }
        params.addBodyParameter("photo", photo);
        params.addBodyParameter("brand", brand);
        params.addBodyParameter("type", type);
        params.addBodyParameter("guideprice", guideprice);
        params.addBodyParameter("sellingprice", sellingprice);
        params.addBodyParameter("carcolor", carcolor);
        params.addBodyParameter("customerservice", customerservice);
        params.addBodyParameter("travel", travel);
        params.addBodyParameter("thefactorytime", thefactorytime);
        params.addBodyParameter("detailedaddress", detailedaddress);
        params.addBodyParameter("detailsa", detailsa);
        params.addBodyParameter("province", province);
        params.addBodyParameter("city", city);
        params.addBodyParameter("area", area);
        params.addBodyParameter("longitude", longitude);
        params.addBodyParameter("latitude", latitude);
        addPOSTPRICODE(params, callback);
    }

    /**
     * 我的租房资源
     *
     * @param callback
     */
    public static void myhousing(Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.RENTOUTMYHOUSING);
        String userid = getUserid();
        params.addBodyParameter("userid", userid);
        addPOSTs(params, callback);
    }

    /**
     * 删除房源
     * id 	房源id
     *
     * @param callback
     */
    public static void myhousingdelhous(String id, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.RENTOUTDELHOUS);
        String userid = getUserid();
        params.addBodyParameter("userid", userid);
        params.addBodyParameter("id", id);
        addPOSTs(params, callback);
    }

    /**
     * 首页
     * @param callback
     */
    public static void homePage( Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Constant.COM + Constant.HOMEPAGE);
        String userid = getUserid();
        params.addBodyParameter("userid", userid);
        addPOSTs(params, callback);
    }
    /**
     * 测试
     */
    public static void testing(RequestParams params, Callback.CommonCallback<String> callback) {

        addPOSTPRICODE(params, callback);
    }
    //Token 字段有变 verifyToken
    private static void addPOST(RequestParams params, Callback.CommonCallback<String> callback) {
        RequestParams para = params;
        String string = SharedPreferencesUtil.getString(SharedPreferencesUtil.Keys.TOKEN_KEYS, "");
        if (!TextUtils.isEmpty(string)) {
            para.addBodyParameter("verifyToken", Sundry.getMD5(string + Constant.PRICODE));
        }
        para.setCacheMaxAge(Constant.HOME_TIME * 1000);
        x.http().request(HttpMethod.POST, para, callback);
        System.out.println("stringmd5result" + para.toString());
    }

    // Token 字段有变 verifiToken
    private static void addPOSTs(RequestParams params, Callback.CommonCallback<String> callback) {
        RequestParams para = params;
        String string = SharedPreferencesUtil.getString(SharedPreferencesUtil.Keys.TOKEN_KEYS, "");
        if (!TextUtils.isEmpty(string)) {
            para.addBodyParameter("verifiToken", Sundry.getMD5(string + Constant.PRICODE));
        }
        para.setCacheMaxAge(Constant.HOME_TIME * 1000);
        x.http().request(HttpMethod.POST, para, callback);
        System.out.println("stringmd5result" + para.toString());
    }

    //没有token
    public static void addPOSTPRICODE(RequestParams params, Callback.CommonCallback<String> callback) {
        RequestParams para = params;
        para.setCacheMaxAge(Constant.HOME_TIME * 1000);
        x.http().request(HttpMethod.POST, para, callback);
        System.out.println("stringmd5result" + para.toString());
    }

    //没有token
    public static void addGET(RequestParams params, Callback.CommonCallback<String> callback) {
        RequestParams para = params;
        para.setCacheMaxAge(Constant.HOME_TIME * 1000);
        x.http().request(HttpMethod.GET, para, callback);
        System.out.println("stringmd5result" + para.toString());
    }


    /**
     * 微信登陆
     * Data 接口
     */
    public static void WeChatlanding(String Data, Callback.CommonCallback<String> callback) {
        RequestParams params = new RequestParams(Data);
        addGET(params, callback);
    }

    private static String getUserid() {
        return SharedPreferencesUtil.getString(SharedPreferencesUtil.Keys.USERID_KEYS, "");
    }
}
